import os
import sys
if 'lib' not in sys.path: 
    sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'lib'))

import logging
from google.appengine.ext.webapp.util import run_wsgi_app
from beaker.middleware import SessionMiddleware

session_opts = {
                'session.type' : 'ext:google',
                'session.cookie_expires' : 300,
                'session.auto' : True
                }

# Start the routes mapper.
from routes.mapper import Mapper
map = Mapper(explicit = True)
from routing import add_routes
add_routes(map)

from wsgi import WSGIApplication
application = WSGIApplication(map, debug = True)
app = SessionMiddleware(wrap_app = application, config = session_opts, environ_key = 'beaker.session')

def main():
	run_wsgi_app(app)

if __name__ == "__main__":
	main()